package leetcode.L35;

class Solution {
    public int searchInsert(int[] nums, int target) {
        int len = nums.length;
        int start = 0;
        int end = len - 1;
        int mid;
        int ans=len;
        while (start <= end) {
            mid = (start + end) / 2;
            if (nums[mid]>=target) {
                ans=mid;
                end = mid-1;
            }  else {
                start = mid+1;
            }
        }
        return ans;
    }

}
